package com.zds.leetcode;

import java.util.LinkedList;
import java.util.List;

public class q_78 {
    public static void main(String[] args) {
        q_78 q_78 = new q_78();
        List<List<Integer>> subsets = q_78.subsets(new int[]{1, 2, 3});
        System.out.println(subsets);
    }

    List<List<Integer>> res = new LinkedList<>();
    LinkedList track = new LinkedList();
    public List<List<Integer>> subsets(int[] nums) {
        backtrack(nums, 0);
        return res;
    }

    void backtrack(int[] nums, int start) {
        res.add(new LinkedList(track));
        for (int i = start; i < nums.length; i++) {
            // 做选择
            track.add(nums[i]);
            backtrack(nums, i + 1);
            track.removeLast();
        }
    }
}
